//------------------------------------------------------------------------------
// X2TK Graphic Toolkit
// Copyright (C) 2006-2007 Janusz Kowalski
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------

#include "x2tk_Container.h"

#include "fontSDL.h"

#ifndef X2TK_SCREEN_H
#define X2TK_SCREEN_H

// Screen is the main object of x2tk. It does physical drawing on the surface.
// It can also draw the mouse pointer, and handle events in the form of
// SDL_Event union.

// Position of the left upper corner and dimensions of the Screen object
// are meaningless. Screen object can use all the surface it is given.
// This is some simplification, because you might want to limit drawing
// only to some area of the surface.

// There's an interesting question concerning Screen attributes like the position
// of upper left corner: Are they a part of the Widget? Or maybe they are
// stored by the parent Widget/Container? Or is Screen ordinary Widget?

namespace x2tk {

class Screen : public Container {
  private:
    SDL_Surface *screen;
    int pointerX;
    int pointerY;
    Image mousePtr;
    Font *font;
    Font *fontLight;
    
    static void toTheTop(Screen *scr);

    // Keeps focus information for this widget.
    bool hasFocus_;
  public:
    Screen(SDL_Surface *screen);
    ~Screen() { }

    virtual bool hasFocus();

    // This function can handle ordinary SDL event in the form of
    // SDL_Event union
    void handleSDLEvent(SDL_Event &event);
    void draw();
    // Blit all the surface to the screen 
    void blitSurface(SDL_Surface *src, int dstX, int dstY);
    void blitSurface(SDL_Surface *src, int x0, int y0, int x, int y, int w, int h);
    void mouseMove(int x, int y);
    virtual short getMouseX();
    virtual short getMouseY();
    void fillRectangle(int x, int y, int w, int h, int r, int g, int b);
    int textWidth(const char *text);
    
    virtual void timed(int id);
};

} // namespace x2tk

#endif
